﻿using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StartsEAS_API.BLL.Interfaces.IAlterStuB;
using StartsEAS_API.Model;
using StartsEAS_API.Model.Models;

namespace StartsEAS_API.Controllers.AlterStuContor
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [EnableCors("any")]
    public class AlterStuController : ControllerBase
    {
        private readonly IAlterStuBLL _alterStu;
        public AlterStuController(IAlterStuBLL alterStuBll) {
            _alterStu = alterStuBll;
        }
        /// <summary>
        /// 无条件查询学生申请表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAllAlterStu() {
            return _alterStu.GetAllAlterStu();
        }
        /// <summary>
        /// 老师/教务处查询学生的旧信息和新修改的信息
        /// </summary>
        /// <param name="stuId">学生编号</param>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAlterStuByStuId(string stuId) {
            return _alterStu.GetAlterStuByStuId(stuId);
        }
        /// <summary>
        /// 查询等待教务处审批的修改信息表信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAllAlterStuStatusIsNotOk() {
            return _alterStu.GetAllAlterStuStatusIsNotOk();
        }
        /// <summary>
        /// 查询等待老师审批的修改信息表信息
        /// </summary>
        /// <param name="token">token</param>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAlterStuByCounselor(string token) {
            return _alterStu.GetAlterStuByCounselor(token);
        }
        /// <summary>
        /// 查询这个老师的学生所有的申请表(包括已处理和未处理)
        /// </summary>
        /// <param name="token">token</param>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAllAlterStuByCounselor(string token) {
            return _alterStu.GetAllAlterStuByCounselor(token);
        }
        /// <summary>
        /// 添加一条学生信息修改申请表
        /// </summary>
        /// <param name="stu">修改表信息</param>
        /// <returns></returns>
        [HttpPost]
        public ResultUtils InsertAlterStu(AlterStu stu) {
            return _alterStu.InsertAlterStu(stu);
        }
        /// <summary>
        /// 老师批阅学生信息申请表
        /// </summary>
        /// <param name="token">老师token</param>
        /// <param name="status">状态 0同意 1拒绝</param>
        /// <param name="stuId">被批阅学号</param>
        /// <returns></returns>
        [HttpPut]
        public ResultUtils AlterStuCounselorApproval(string token, int status, string stuId) {
            return _alterStu.AlterStuCounselorApproval(token, status, stuId);
        }
        /// <summary>
        /// 教务处批阅学生信息申请表
        /// </summary>
        /// <param name="token">教务处token</param>
        /// <param name="status">状态 0同意 1拒绝</param>
        /// <param name="stuId">被批阅学号</param>
        /// <returns></returns>
        [HttpPut]
        public ResultUtils AlterStuDeptApproval(string token, int status, string stuId) {
            return _alterStu.AlterStuDeptApproval(token, status, stuId);
        }
        /// <summary>
        /// 根据状态查询学生信息申请表
        /// </summary>
        /// <param name="status">批阅状态</param>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils AlterStuByStatus(int status) {
            return _alterStu.AlterStuByStatus(status);
        }
        /// <summary>
        /// 查询该学生的所有申请记录
        /// </summary>
        /// <param name="token">学生token</param>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAllTheRecordsByToken(string token){
            return _alterStu.GetAllTheRecordsByToken(token);   
        }

    }
}
